<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>Insert title here</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/font-awesome.min.css" />

<!-- page specific plugin styles -->

<!-- text fonts -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-fonts.css" />

<!-- ace styles -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace.min.css"
	id="main-ace-style" />

<!--[if lte IE 9]>
			<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-part2.min.css" />
		<![endif]-->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-skins.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/assets/css/ace-rtl.min.css" />

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/static/css/exam.css" />

<!--[if lte IE 9]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/ace-ie.min.css" />
		<![endif]-->

<!-- inline styles related to this page -->

<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/assets/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/lib/jquery-1.11.1.min.js"></script>

<!-- ace settings handler -->
<script
	src="${pageContext.request.contextPath}/static/assets/js/ace-extra.min.js"></script>

</head>
<body>
	<div class="exam-wrapper">
		<header>
		<div class="timer">
			<span id="testTimer"></span>
		</div>
		<h2>${subject.name}</h2>
		</header>
		<hr>
		<div class="content">
			<p class="alert alert-success">本次考试的参考时长为：${subject.total_time}
				分钟&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;总分为：${subject.total_score}分</p>
			<div class="testList">
				<form action="checkAnswer/${subject.id}" id="examForm" method="post">
					<%
						int index = 0;
					%>
					<c:forEach items="${map}" var="testMap">
						<c:forEach items="${testMap.value}" var="test">
							<div class="test-content">
								<h4>
									<%
										index++;
										out.print(index);
									%>、<span>${test.examTestType.testType}&nbsp;</span>
									(${test.examTestType.testTypeScore}分) ${test.content}
								</h4>
								<div class="control-group testCount testCount<%out.print(index);%>">
									<c:if test="${test.testTypeId==1}">
										<div class="radio">
											<label> <input name="test_${test.id}" value="A"
												type="radio" class="ace"/> <span class="lbl">&nbsp;&nbsp;&nbsp;${test.chooseA}</span>
											</label>
										</div>
										<div class="radio">
											<label> <input name="test_${test.id}" value="B"
												type="radio" class="ace" /> <span class="lbl">&nbsp;&nbsp;${test.chooseB}</span>
											</label>
										</div>
										<div class="radio">
											<label> <input name="test_${test.id}" value="C"
												type="radio" class="ace" /> <span class="lbl">&nbsp;&nbsp;${test.chooseC}</span>
											</label>
										</div>
										<div class="radio">
											<label> <input name="test_${test.id}" value="D"
												type="radio" class="ace" /> <span class="lbl">&nbsp;&nbsp;${test.chooseD}</span>
											</label>
										</div>
									</c:if>
									<c:if test="${test.testTypeId==2}">
										<!-- #section:custom/checkbox -->
										<div class="checkbox">
											<label> <input type="checkbox" name="test_${test.id}"
												value="A" class="ace" /> <span class="lbl">
													&nbsp;&nbsp;&nbsp;${test.chooseA}</span>
											</label>
										</div>
										<div class="checkbox">
											<label> <input type="checkbox" name="test_${test.id}"
												value="B" class="ace"/> <span class="lbl"> 
													&nbsp;&nbsp;&nbsp;${test.chooseB}</span>
											</label>
										</div>
										<div class="checkbox">
											<label> <input type="checkbox" name="test_${test.id}"
												value="C" class="ace" /> <span class="lbl">
													&nbsp;&nbsp;&nbsp;${test.chooseC}</span>
											</label>
										</div>
										<div class="checkbox">
											<label> <input type="checkbox" name="test_${test.id}"
												value="D" class="ace"/> <span class="lbl">
													&nbsp;&nbsp;&nbsp;${test.chooseD}</span>
											</label>
										</div>
									</c:if>
								</div>
							</div>
							<hr>
						</c:forEach>
					</c:forEach>
					<div class="exam-btn">
						<button class="btn btn-info exam-submit" type="button">
							<i class="ace-icon fa fa-check bigger-110"></i> 提交
						</button>
						&nbsp; &nbsp; &nbsp;
						<a href="${pageContext.request.contextPath}/student/subjects" class="btn btn-default exam-out">
							<i class="ace-icon fa fa-times bigger-125"></i> 退出
						</a>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>


<script type="text/javascript">
	
</script>

<script
	src="${pageContext.request.contextPath}/static/assets/js/ace/elements.onpage-help.js"></script>
<script
	src="${pageContext.request.contextPath}/static/assets/js/ace/ace.onpage-help.js"></script>
<script
	src="${pageContext.request.contextPath}/static/docs/assets/js/rainbow.js"></script>
<script
	src="${pageContext.request.contextPath}/static/docs/assets/js/language/generic.js"></script>
<script
	src="${pageContext.request.contextPath}/static/docs/assets/js/language/html.js"></script>
<script
	src="${pageContext.request.contextPath}/static/docs/assets/js/language/css.js"></script>
<script
	src="${pageContext.request.contextPath}/static/docs/assets/js/language/javascript.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/lib/ajaxfileupload.js"></script>
<script
	src="${pageContext.request.contextPath}/static/lib/jquery.jqprint-0.3.js"></script>

<script
	src="${pageContext.request.contextPath}/static/lib/jquery-migrate-1.2.1.js"></script>

<script type="text/javascript">
	$('.exam-submit').click(function(){
		var con = confirm("是否提交？");
		if (con) {
 		$('#examForm').submit();
		}
	})
	
	function initTimer(){
		var resultTime=0;
		var testTotalTime=Number('${subject.total_time}');
		return testTotalTime*60;
	}
	
	function startTimer(totalSecend){
		$('#testTimer').text(formatTime(totalSecend));
		var timer=setInterval(function(){
			totalSecend--;
			if(totalSecend>=0){
				$('#testTimer').text(formatTime(totalSecend));
				//更新COOKIE
			}else{
				alert('考试结束！');
				clearInterval(timer);
		 		$('#examForm').submit();
			}
		},1000);
	}
	
	function formatTime(totalSecend){
		var hour=Math.floor(totalSecend/3600);
		var min=Math.floor((totalSecend%3600)/60);
		var secend=(totalSecend%60);
		hour=formatTimeNumber(hour);
		min=formatTimeNumber(min);
		secend=formatTimeNumber(secend);
		return hour+':'+min+':'+secend;
	}
	
	function formatTimeNumber(timeNumber){
		if(timeNumber<10){
			return "0"+timeNumber;
		}else{
			return timeNumber;
		}
	}
	startTimer(initTimer());
	
</script>



</html>